<?php
session_start();

if(!isset($_SESSION['last_key'])) {
  echo '{"error_code":0, "error":"Not logged in"}';
  return;
}

include_once('config.php');
include_once('weibooauth.php');

$c = new WeiboClient( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret']  );
$with_new_status = 0;
if (isset($_GET['with_new_status']) && $_GET['with_new_status'] == 1) {
  $with_new_status = 1;
}
$msg = $c->get_unread($with_new_status);
echo json_encode($msg);
?>